#include "Bishop.h"

Bishop::Bishop(enum FigureColor color) : Figure(color)
{
}

QString Bishop::getImage() const
{
    if(color == BLACK)
        return "./images/blackbishop.png";
    else
        return "./images/whitebishop.png";
}

AllMoves Bishop::moves() const
{
    AllMoves m;
    int x, y, position[2];

    Position::position2index(currentPosition, position);

    //lewo-gora
    y = position[0];
    x = position[1];
    while(--y >= 0 && --x >= 0) {
        QVector<int> coords(2);
        coords[0] = y;
        coords[1] = x;

        m.append(coords);
    }

    //prawo-gora
    y = position[0];
    x = position[1];
    while(--y >= 0 && ++x <= 7) {
        QVector<int> coords(2);
        coords[0] = y;
        coords[1] = x;

        m.append(coords);
    }

    //lewo-dół
    y = position[0];
    x = position[1];
    while(++y <= 7 && --x >= 0) {
        QVector<int> coords(2);
        coords[0] = y;
        coords[1] = x;

        m.append(coords);
    }

    //prawo-dół
    y = position[0];
    x = position[1];
    while(++y <= 7 && ++x <= 7) {
        QVector<int> coords(2);
        coords[0] = y;
        coords[1] = x;

        m.append(coords);
    }

    return m;
}
